<?php
  include '../model/db.php';
  include '../model/fn.php';
  if($_GET['type']=='sc'&&$_GET['id']) {
    $sql = "select count(*) as co from bl_class where pid = '{$_GET['id']}'";
    $co = db_sel($sql);
    if ($co['co'] > 0) {
      echo "<script>alert('存在二级分类不能删除');location.href='./catelist.php'</script>";
      exit();
    }

    $del = "delete from bl_class where id ='{$_GET['id']}'";
//    var_dump(db_query($del));
    if (db_del($del)) {
      echo "<script>alert('删除成功')</script>";
    }else{
      echo "<script>alert('删除失败')</script>";
    }
  }
  $sql="select * from bl_class";
  $arr=db_sel($sql,2);
  $list=fl($arr);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>后台 管理中心 - 文章分类 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../public/admin/styles/general.css" rel="stylesheet" type="text/css" />
<link href="../public/admin/styles/main.css" rel="stylesheet" type="text/css" />
<script type = 'text/javascript' src = '/app/view/js/jquery-1.4.2.min.js'></script>
</head>
<body>

<h1>
<span class="action-span"><a href="./cateadd.php">添加分类</a></span>
<span class="action-span1"><a href="#">后台 管理中心</a> </span><span id="search_id" class="action-span1"> - 文章分类 </span>
<div style="clear:both"></div>
</h1>
<form method="post" action="" name="listForm">
<div class="list-div" id="listDiv">

<table width="100%" cellspacing="1" cellpadding="2" id="list-table">
  <tr>
    <th>分类id</th>
    <th>分类名称</th>
    <th>上级id</th>
    <th>操作</th>
  </tr>
  <?php foreach($list as $v){?>
  <tr>
    <td><?php echo $v['id']?></td>
    <td><?php if($v['pid']=='0'){echo $v['name'];}else{echo "&nbsp;&nbsp;&nbsp;".$v['name'];} ?></td>
    <td><?php echo $v['pid']?></td>
    <td><a href="./cateupd.php?id=<?php echo $v['id']; ?>">修改</a>
      |<a href="./catelist.php?type=sc&id=<?php echo $v['id']; ?>">删除</a></td>
  </tr>
  <?php }?>
  </table>
</div>
</form>

<div id="footer">
共执行 1 个查询，用时 0.015927 秒，Gzip 已禁用，内存占用 1.999 MB<br />

版权所有 &copy; 2005-2010 上海商派网络科技有限公司，并保留所有权利
。</div>

</body>
</html>